library(tidyverse)

figure_map <- read_csv("../data/bazaars_figure_map.csv")
table_map <- read_csv("../data/bazaars_table_map.csv")

table_map$publication_reference <- gsub("main_", "", table_map$publication_reference)
figure_map$publication_reference <- gsub("main_", "", figure_map$publication_reference)
figure_map$publication_reference <- gsub("figure_", "fg", figure_map$publication_reference)

for (i in 1:nrow(figure_map)) {
  from <- paste0("../results/figures/",
    figure_map$original_reference[i],
    ".pdf")

  to <- paste0("../results/for_publication/figures/",
    figure_map$publication_reference[i],
    ".pdf")
  
  file.copy(from, to, overwrite = TRUE)
}

for (i in 1:nrow(table_map)) {
  from <- paste0("../results/tables/",
    table_map$original_reference[i],
    ".tex")

  to <- paste0("../results/for_publication/tables/",
    table_map$publication_reference[i],
    ".tex")
  
  file.copy(from, to, overwrite = TRUE)
}

message("Replication completed!")